home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
earkit
/
news
/
thor
/
rexx
/
bbsread
/
copymessage.br
< prev
next >
Wrap
Text File
|
1998-05-24
|
7KB
|
243 lines
/*
** $VER: CopyMessage.br 1.2 (19.9.97)
** by Eirik Nicolai Synnes
**
** See SortMail.guide for documentation
**
*/
options results
options failat 31
parse arg arguments
/*
** Initialize some variables
*/
version = subword(sourceline(2), 4, 1)
template = 'SYSTEM/A,CONFERENCE/A,MSGNO/A,DESTCONF/A,DESTSYS/K,REPLYADDR/K'
CDB_MARK_OWN_MSGS = 22 /* Also mark messages from user when adding messages. */
CDF_NOT_ON_BBS = '00008000'x /* This conference is not on the bbs. */
CDNT_NONET = 0 /* This conference is a local conference. This is the default values for new conferences. */
CDNT_MAILFOLDER = 3 /* This conference is a virtual mail folder */
MDB_READ = 0 /* Message is read. */
MDB_REPLIED = 1 /* Message is replied. */
MDB_PRIVATE = 2 /* Message is private. */
MDB_DELETED = 5 /* Message is deleted. */
MDB_KEEP = 7 /* Keep message. Message will not be deleted during conference packing. */
MDB_MARKED = 10 /* Message is marked. */
MDB_URGENT = 11 /* Message is urgent. */
MDB_IMPORTANT = 12 /* Message is important. */
MDB_SUPERMARKED = 13 /* Message will not be unmarked as long as this flag is set. */
MDB_CONFIDENTIAL = 17 /* Message is confidential. */
/*
** Find/open BBSREAD ARexx port
*/
if ~show('P', 'BBSREAD') then do
address(command)
'Run >NIL: `GetEnv THOR/THORPath`bin/LoadBBSRead'
if exists('SYS:RexxC/WaitForPort') then 'SYS:RexxC/WaitForPort BBSREAD'
else 'WaitForPort BBSREAD'
if (rc = 5) then do; say 'Could not open BBSREAD''s ARexx port.'; exit(30); end
if (rc ~= 0) then do; say 'Could not find SYS:Rexxc/WaitForPort.'; exit(30); end
end
/*
** Give template if arguments = '?' or empty
*/
if (arguments = '?') | (arguments = '') then do
say 'Usage: 'template
say 'CopyMessage.br is an external script for SortMail.'
exit(5)
end
address(bbsread)
'READARGS "'template'" 'args' CMDLINE 'arguments
if (rc ~= 0) then do
say BBSREAD.LASTERROR
say 'Template: 'template
say 'CopyMessage.br is an external script for SortMail.'
exit(5)
end
/*
** Utilize BBSRead's copyback buffer
*/
address(bbsread)
'BUFMODE COPYBACK'
/*
** Read message's header and text stems, exit if it's deleted
*/
'READBRMESSAGE "'args.SYSTEM'" "'args.CONFERENCE'" 'args.MSGNO' HEADSTEM 'head' DATASTEM 'data' TEXTSTEM 'text
if (rc ~= 0) then signal error
if (bittst(data.FLAGS, MDB_DELETED)) then do; myerr = 'Message was deleted.'; rc = 20; signal error; end
/*
** Create header for new message
*/
text.fromname = head.FROMNAME
if (symbol('head.FROMADDR') = 'VAR') then text.fromaddr = head.FROMADDR
if (symbol('head.TONAME') = 'VAR') then text.toname = head.TONAME
if (symbol('head.TOADDR') = 'VAR') then text.toaddr = head.TOADDR
if (symbol('head.MSGID') = 'VAR') then text.msgid = head.MSGID
if (symbol('head.REFID') = 'VAR') then text.refid = head.REFID
if (symbol('head.CREATIONDATE') = 'VAR') then text.creationdate = head.CREATIONDATE
if (symbol('head.CREATIONDATETXT') = 'VAR') then text.creationdatetxt = head.CREATIONDATETXT
if (symbol('head.SUBJECT') = 'VAR') then text.subject = head.SUBJECT
text.replyconf = args.CONFERENCE
/*
** Find a reply address from the arguments or the original message
*/
drop text.replyname
if (symbol('args.REPLYADDR') ~= 'VAR') then do
if (symbol('text.REPLYADDR') ~= 'VAR') then do
text.replyaddr = head.FROMADDR
if (symbol('head.FROMNAME') = 'VAR') then text.replyname = head.FROMNAME
end
end
else text.replyaddr = args.REPLYADDR
/*
** Make sure args.DESTSYS contains something and get system configuration
** for destination
*/
if (symbol('args.DESTSYS') ~= 'VAR') then args.DESTSYS = args.SYSTEM
'GETBBSDATA "'args.DESTSYS'" 'bbsdata
if (rc ~= 0) then signal error
/*
** See if the conference the msg will be written to exists
*/
'GETCONFLIST BBSNAME "'args.DESTSYS'" STEM 'conflist
if (rc ~= 0) then signal error
do n = 1 to conflist.COUNT + 1 while upper(args.DESTCONF) ~= upper(conflist.n)
if (n = conflist.COUNT + 1) then do
/* Create the new conference */
'CONFIGCONF "'args.DESTSYS'" "'args.DESTCONF'"'
if (rc ~= 0) then signal error
'GETCONFDATA "'args.DESTSYS'" "'args.DESTCONF'" STEM 'confdata
if (rc ~= 0) then signal error
if (confdata.CONFNETTYPE = CDNT_NONET) then do
'CONFIGCONF "'args.DESTSYS'" "'args.DESTCONF'" CONFNETTYPE 'CDNT_MAILFOLDER' SET 'c2x(CDF_NOT_ON_BBS)
if (rc ~= 0) then signal error
end
end
end
drop conflist.
/*
** Set the selected message flags
*/
writeflags = ''
if (bittst(data.FLAGS, MDB_READ)) then writeflags = writeflags || 'READ '
if (bittst(data.FLAGS, MDB_PRIVATE)) then writeflags = writeflags || 'PRIVATE '
if (bittst(data.FLAGS, MDB_URGENT)) then writeflags = writeflags || 'URGENT '
if (bittst(data.FLAGS, MDB_IMPORTANT)) then writeflags = writeflags || 'IMPORTANT '
if (bittst(data.FLAGS, MDB_CONFIDENTIAL)) then writeflags = writeflags || 'CONFIDENTIAL '
updateflags = ''
if (bittst(data.flags, MDB_REPLIED)) then updateflags = updateflags || 'SETREPLIED '
if (bittst(data.flags, MDB_KEEP)) then updateflags = updateflags || 'SETKEEP '
if (bittst(data.flags, MDB_SUPERMARKED)) then updateflags = updateflags || 'SETSUPERUNREAD '
if (symbol('data.HAZELEVEL') = 'VAR') & (data.HAZELEVEL > 0) then updateflags = updateflags || 'HAZELEVEL 'data.HAZELEVEL' '
/*
** Mark message as unread only if Show own messages is not activated
*/
'GETCONFDATA "'args.DESTSYS'" "'args.DESTCONF'" STEM 'confdata
if (rc ~= 0) then signal error
if ~(bittst(confdata.FLAGS, CDB_MARK_OWN_MSGS)) & (upper(head.FROMADDR) = upper(bbsdata.EMAILADDR)) then writeflags = writeflags || 'DONTMARKMESSAGE '
/*
** Write the message
*/
address(bbsread)
'WRITEBRMESSAGE "'args.DESTSYS'" "'args.DESTCONF'" STEM 'text' 'writeflags
if (rc ~= 0) then signal error
msgnr = result
/*
** If the new message's number is -1 then it was caught by a kill
*/
if (msgnr ~= -1) then do
/*
** Give the new message it's flags
*/
if (updateflags ~= '') then do
'UPDATEBRMESSAGE "'args.DESTSYS'" "'args.DESTCONF'" 'msgnr' 'updateflags
if (rc ~= 0) then signal error
end
end
returned = 0; signal cleanup
/*
** Some error detection stuff
*/
error:
syntax:
returned = rc
select
when symbol('BBSREAD.LASTERROR') = 'VAR' then say 'Line 'sigl' returned 'returned': 'BBSREAD.LASTERROR
when symbol('myerr') = 'VAR' then say 'Line 'sigl' returned 'returned': 'myerr
otherwise say 'Line 'sigl' returned 'returned': 'errortext(returned)
end
break_c:
halt:
cleanup:
/*
** Turn off copyback buffer
*/
address(bbsread)
'BUFMODE ENDCOPYBACK'
exit(returned)